define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function ($, undefined, Backend, Table, Form, undefined) {
    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'video/index' + location.search,
                    add_url: 'video/add',
                    edit_url: 'video/edit',
                    del_url: 'video/del',
                    multi_url: 'video/multi',
                    import_url: 'video/import',
                    table: 'video',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'category_id', title: __('分类'),operate:'LIKE'},
                        {field: 'video_name', title: __('视频名称'), editable: true,operate:'LIKE'},
                        {field: 'year', title: __('Year'), editable: true},
                        {field: 'url', title: __('视频'), editable: true},
                        {field: 'pic', title: __('图片'), editable: true},
						{field: 'platform_name', title: __('平台来源'), operate: false,},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
			 formatter:{
                platform: function (value, row, index) {
					var platform_name = '无';
                    if(value == 1){
						platform_name = '本站';
					}else if(value == 2){
						platform_name = '考试宝典';
					}else if(value == 3){
						platform_name = '助考宝典';
					}
					return platform_name;
                },
            },
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
